package com.cet.test.mt04.qz4;

/**
 * @program: cet-practice
 * @description:
 * @author: 陈恩涛
 * @create: 2023-05-06 21:41
 **/
public class Node {

    int val;

    Node next;

    Node() {}

    Node(int val) { this.val = val; }

    Node(int val, Node next) { this.val = val; this.next = next; }

    public static Node init(int... a) {
        Node dummy = new Node();
        Node current = dummy;
        for (int i : a) {
            current.next = new Node(i);
            current = current.next;
        }
        return dummy.next;
    }

    @Override
    public String toString() {
        return "Node{" +
            "val=" + val +
            ", next=" + next +
            '}';
    }
}
